#!/usr/bin/env bash

amixer set Master 5%-

function get_volume {
    amixer get Master | grep '%' | head -n 1 | cut -d '[' -f 2 | cut -d '%' -f 1
}

function generate_bar {
    local vol=$1
    local num_bars=$((vol / 5))
    bar=$(printf '─%.0s' $(seq $num_bars))
}

function send_notification {
    volume=$(get_volume)
    generate_bar $volume

    if [ $volume -eq 0 ]; then
        dunstify -r 2593 "Volume: Muted"
    else
        dunstify -r 2593 "Volume: $volume%" "$bar"
    fi
}
send_notification
